{extend name='base'/}
{block name='content'}

<script src="__STATIC__/uploadify/jquery.uploadify.js"></script>
<link rel="stylesheet" href="__STATIC__/uploadify/uploadify.css">
<script src="__STATIC__/ueditor1_4_3/ueditor.config.js"></script>
<script src="__STATIC__/ueditor1_4_3/ueditor.all.js"></script>
<ul class="breadcrumb no-border no-radius b-b b-light pull-in">
    <li><a href="index.html"><i class="fa fa-home"></i> Home</a></li>
    <li><a href="#">商品管理</a></li>
    <li class="active">商品添加</li>
</ul>
<div class="col-sm-12">
    <section class="panel panel-default">
        <header class="panel-heading font-bold">商品添加</header>
        <div class="panel-body">
            <form method="post" action="" class="bs-example form-horizontal" enctype="multipart/form-data">
                <table class="table table-hover">
                    <tbody>
                    <tr width="20%">
                        <td>分类</td>
                        <td width="80%">
                            <select name="cid" id="">
                                <option value="0">请选择分类</option>
                                {volist name="cateList" id="vo"}
                                <option  value="{$vo['cid']}"> -- {$vo['_cname']} -- </option>
                                {/volist}
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>商品名</td>
                        <td>
                            <div class="form-group">
                                <input type="text" class="form-control" name="gname" >
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>商品描述</td>
                        <td>
                            <div class="form-group">
                                <input type="text" class="form-control" name="description" >
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>货号</td>
                        <td>
                            <div class="form-group">
                                <input type="text" class="form-control" name="gnumber" >
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>记件单位</td>
                        <td>
                            <div class="form-group">
                                <input type="text" class="form-control" name="unit" value="件">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>市场价</td>
                        <td>
                            <div class="form-group">
                                <input type="text" class="form-control" name="marketprice" value="0">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>商城价</td>
                        <td>
                            <div class="form-group">
                                <input type="text" class="form-control" name="shopprice" value="0">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>颜色</td>
                        <td id="GoodsAttrBox">
                            <textarea class="form-control" name="color" cols="10" rows="2" placeholder="红色|白色|蓝色"></textarea>
                            <span class="help-block">请按照：红色|白色|蓝色  输入</span>
                        </td>
                    </tr>
                    <tr>
                        <td>尺码</td>
                        <td id="GoodsSpecBox">
                            <textarea class="form-control" name="size" cols="30" rows="2" placeholder="请按照：X|XXl|XXXL  输入"></textarea>
                            <span class="help-block">请按照：X|XXl|XXXL  输入</span>
                        </td>
                    </tr>
                    <tr>
                        <td>列表图</td>
                        <td>
                            <div class="col-lg-10">
                                <input type="file" name="pic" id="thumb">
                            </div>
                            <div class="row" id="uploadBox">

                            </div>
                            <script>
                                $(function() {
                                    $("#thumb").uploadify({
                                        buttonText : '上传',
                                        buttonClass : 'bgred',
                                        'removeTimeout' : 10,
                                        height        : 30,
                                        swf           : '__STATIC__/uploadify/uploadify.swf',
                                        uploader      : "{:url('admin/brand/ajaxUpload',['tpl'=>'uploadTpl'])}",
                                        width         : 120,
                                        onUploadSuccess : function(file, data, response) {
                                            var img = '<li><img style="width: 120px;" src="'+data+'" alt=""> <input type="hidden" name="pic" value="'+data+'"> </li>';
                                            $('#uploadBox').append(img);
                                        }
                                    });
                                });
                            </script>
                        </td>
                    </tr>
                    <tr>
                        <td>商品图册</td>
                        <td>
                            <div class="col-lg-10">
                                <input type="file" name="ggpic[]" id="ggPicBox">
                            </div>
                            <br>
                            <div class="row" id="ggPicBox">

                            </div>
                            <script>
                                $(function() {
                                    $("#ggPicBox").uploadify({
                                        buttonText : '上传',
                                        buttonClass : 'deepskyblue',
                                        'removeTimeout' : 10,
                                        height        : 30,
                                        swf           : '__STATIC__/uploadify/uploadify.swf',
                                        uploader      : "{:url('admin/brand/ajaxUpload',['tpl'=>'uploadTpl'])}",
                                        width         : 120,
                                        onUploadSuccess : function(file, data, response) {
                                            var img = '<li style="width: 400px"><img style="width: 120px; list-style: none; " src="'+data+'" alt=""><br> <input type="hidden" name="ggpic[]" value="'+data+'"> </li>';
                                            $('#uploadBox').append(img);
                                        }
                                    });
                                });
                            </script>
                        </td>
                    </tr>
                    <tr>
                        <td>点击次数</td>
                        <td>
                            <div class="form-group">
                                <input type="text" class="form-control" name="click" value="0">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>库存</td>
                        <td>
                            <div class="form-group">
                                <input type="text" class="form-control" name="total" value="0">
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>商品详情</td>
                        <td>
                            <textarea style="width:100%" id="intro" name="intro" cols="30" rows="10"></textarea>
                            <!-- 实例化编辑器 -->
                            <script type="text/javascript">
                                var ue = UE.getEditor('intro');
                            </script>
                        </td>
                    </tr>
                    <tr>
                        <td>售后服务</td>
                        <td>
                            <textarea style="width:100%" id="service" name="service" cols="30" rows="10"></textarea>
                            <!-- 实例化编辑器 -->
                            <script type="text/javascript">
                                var ue = UE.getEditor('service');
                            </script>
                        </td>
                    </tr>
                    <tr>
                        <th colspan="2">
                            <input type="submit" value="保存" class="btn btn-success btn-block">
                        </th>
                    </tr>
                    </tbody>
                </table>
            </form>
        </div>
    </section>
</div>
<style>
    .bgred{
        background: red;
    }
    .deepskyblue{
        background: deepskyblue;
    }
</style>
<script>
    $('[name=tid]').change(function(){
        var tid = $(this).val();
        var cid = $(this).find('option:selected').attr('cid');
        $('input[name=cid]').val(cid);
        //获得普通属性模板
        $.get("{:url('admin/goods/getGoodsAttr')}",{tid:tid,class:0,tpl:'goodsAttrTpl'},function(data){
            $('#GoodsAttrBox').html(data);
        })
        //获得规格模板
        $.get("{:url('admin/goods/getGoodsAttr')}",{tid:tid,class:1,tpl:'goodsSpecTpl'},function(data){
            $('#GoodsSpecBox').html(data);
        })
    })
</script>
{/block}




